
<style>
    .xxpayPopupDiv .layui-form-label {
        width:15% !important;
        margin-left:1%;
    }
    .xxpayPopupDiv .layui-input-inline {
        width: 33% !important;
        margin-top: 0px;
    }
    .xxpayPopupDiv .layui-table-label {
        margin-left:1%;
        margin-right:1%;
    }
</style>
<div class="layui-fluid">
  <div class="layui-card">
    <div class="layui-tab layui-tab-brief">
      <div class="layui-tab-content">
          <form class="layui-form layui-form-pane" action="">
              <div class="layui-form-item">
                  <label class="layui-form-label">红包名称</label>
                  <div class="layui-input-inline">
                      <input type="text" id="couponName" disabled="disabled" class="layui-input">
                  </div>
                  <label class="layui-form-label">红包描述</label>
                  <div class="layui-input-inline">
                      <input type="text" id="prizeMsg" disabled="disabled" class="layui-input">
                  </div>
              </div>
              <div class="layui-form-item">
                  <label class="layui-form-label">发送方式</label>
                  <div class="layui-input-inline">
                      <input type="text" id="prizeType" disabled="disabled" class="layui-input">
                  </div>
                  <label class="layui-form-label">发放总金额(元)</label>
                  <div class="layui-input-inline">
                      <input type="text" id="totalMoney" disabled="disabled" class="layui-input">
                  </div>
              </div>
              <div class="layui-form-item">
                  <label class="layui-form-label">红包个数</label>
                  <div class="layui-input-inline">
                      <input type="text" id="totalNum" disabled="disabled" class="layui-input">
                  </div>
                  <label class="layui-form-label">用户参与次数</label>
                  <div class="layui-input-inline">
                      <input type="text" id="sendFreqency" disabled="disabled" class="layui-input">
                  </div>
              </div>
              <div class="layui-form-item">
                  <label class="layui-form-label">任务状态</label>
                  <div class="layui-input-inline">
                      <input type="text" id="taskStatus" disabled="disabled" class="layui-input">
                  </div>
                  <label class="layui-form-label">账户模板ID</label>
                  <div class="layui-input-inline">
                      <input type="text" id="accountTemplateId" disabled="disabled" class="layui-input">
                  </div>
              </div>
              <div class="layui-form-item">
                  <label class="layui-form-label">支付宝红包状态</label>
                  <div class="layui-input-inline">
                      <input type="text" id="alipayStatus" disabled="disabled" class="layui-input">
                  </div>
              </div>
              <div class="layui-form-item">
                  <label class="layui-form-label">红包活动号</label>
                  <div class="layui-input-inline">
                      <input type="text" id="alipayCrowdNo" disabled="disabled" class="layui-input">
                  </div>
                  <label class="layui-form-label">原始活动号</label>
                  <div class="layui-input-inline">
                      <input type="text" id="alipayOriginCrowdNo" disabled="disabled" class="layui-input">
                  </div>
              </div>
              <div class="layui-form-item">
                  <label class="layui-form-label">已发放金额(元)</label>
                  <div class="layui-input-inline">
                      <input type="text" id="alipaySendAmount" disabled="disabled" class="layui-input">
                  </div>
                  <label class="layui-form-label">付款链接</label>
                  <div class="layui-input-inline">
                      <input type="text" id="alipayPayUrl" disabled="disabled" class="layui-input">
                  </div>
              </div>
              <div class="layui-form-item">
                  <label class="layui-form-label">错误信息</label>
                  <div class="layui-input-inline">
                      <input type="text" id="alipayErrorMsg" disabled="disabled" class="layui-input">
                  </div>
              </div>
              <div class="layui-form-item">
                  <label class="layui-form-label">开始时间</label>
                  <div class="layui-input-inline">
                      <input type="text" id="startTime" disabled="disabled" class="layui-input">
                  </div>
                  <label class="layui-form-label">结束时间</label>
                  <div class="layui-input-inline">
                      <input type="text" id="endTime" disabled="disabled" class="layui-input">
                  </div>
              </div>
              <div class="layui-form-item">
                  <label class="layui-form-label">创建时间</label>
                  <div class="layui-input-inline">
                      <input type="text" id="createTime" disabled="disabled" class="layui-input">
                  </div>
                  <label class="layui-form-label">更新时间</label>
                  <div class="layui-input-inline">
                      <input type="text" id="updateTime" disabled="disabled" class="layui-input">
                  </div>
              </div>
          </form>
      </div>
        <div class="layui-tab layui-tab-brief">
            <ul class="layui-tab-title">
                <li class="layui-this">红包领取详情</li>
            </ul>


            <div>

                <div style="padding:10px 20px">
                    <table id="XxPay_Mgr_Alipay_Cash_detail" lay-filter="XxPay_Mgr_Alipay_Cash_detail"></table>
                </div>

            </div>
        </div>
    </div>
  </div>
</div>

<script>
    layui.use(['admin','form', 'table'],function(){
        var form = layui.form
        ,$ = layui.$
        ,admin = layui.admin
        ,table = layui.table
        ,element = layui.element
        ,view = layui.view
        ,layer = layui.layer ;
        // 导航
        element.render('breadcrumb', 'breadcrumb');
        var id = view.getOpenParams('id');
        admin.req({
            type: 'get',
            url: layui.setter.baseUrl + '/alipayCash/get',
            data: {
                id : id
            },
            error: function(err){
                layer.alert(JSON.stringify(err.field), {
                    title: '错误提示'
                })
            },
            success: function(res){
                if(res.code == 0){
                    $('#couponName').val(res.data.couponName);
                    $('#prizeMsg').val(res.data.prizeMsg);
                    $('#totalNum').val(res.data.totalNum);
                    $('#sendFreqency').val(res.data.sendFreqency);
                    $('#accountTemplateId').val(res.data.accountTemplateId);
                    $('#alipayCrowdNo').val(res.data.alipayCrowdNo);
                    $('#alipayOriginCrowdNo').val(res.data.alipayOriginCrowdNo);
                    $('#alipayPayUrl').val(res.data.alipayPayUrl);
                    $('#alipayErrorMsg').val(res.data.alipayErrorMsg);
                    if (res.data.taskStatus == 0) {
                        $('#taskStatus').val("创建失败");
                    }else if (res.data.taskStatus == 1) {
                        $('#taskStatus').val("创建成功");
                    }else if (res.data.taskStatus == 2) {
                        $('#taskStatus').val("红包发放中");
                    }else if (res.data.taskStatus == 3) {
                        $('#taskStatus').val("红包发放完成");
                    }else if (res.data.taskStatus == 4) {
                        $('#taskStatus').val("已取消发放");
                    }
                    if (res.data.prizeType == 'random'){
                        $('#prizeType').val("随机金额");
                    } else if (res.data.prizeType == 'fixed') {
                        $('#prizeType').val("固定金额");
                    }
                    if (res.data.alipayStatus == 'CREATED') {
                        $('#alipayStatus').val("已创建未打款");
                    }else if (res.data.alipayStatus == 'PAID') {
                        $('#alipayStatus').val("已打款");
                    }else if (res.data.alipayStatus == 'READY') {
                        $('#alipayStatus').val("活动已开始");
                    }else if (res.data.alipayStatus == 'PAUSE') {
                        $('#alipayStatus').val("活动已暂停");
                    }else if (res.data.alipayStatus == 'CLOSED') {
                        $('#alipayStatus').val("活动已结束");
                    }else if (res.data.alipayStatus == 'SETTLE') {
                        $('#alipayStatus').val("活动已清算");
                    }
                    $('#totalMoney').val(res.data.totalMoney/100);
                    $('#alipaySendAmount').val(res.data.alipaySendAmount/100);
                    if(res.data.startTime != "" && res.data.startTime != null) {
                        $('#startTime').val(layui.util.toDateString(res.data.startTime));
                    }
                    if(res.data.endTime != "" && res.data.endTime != null) {
                        $('#endTime').val(layui.util.toDateString(res.data.endTime));
                    }
                    if(res.data.createTime != "" && res.data.createTime != null) {
                        $('#createTime').val(layui.util.toDateString(res.data.createTime));
                    }
                    if(res.data.updateTime != "" && res.data.updateTime != null) {
                        $('#updateTime').val(layui.util.toDateString(res.data.updateTime));
                    }
                    form.render();
                }
            }
        });

        var tplStatus = function(d){
            if(d.status == 0) {
                return "<span style='color: goldenrod'>待发放</span>";
            }else if (d.status == 1){
                return "<span style='color: green'>分账成功</span>";
            }else if (d.status == 2){
                return "<span style='color: red'>分账失败</span>";
            }else if (d.status == 3){
                return "<span style='color: red'>已取消发放</span>";
            }
        };

        //领红包明细
        table.render({
            elem: '#XxPay_Mgr_Alipay_Cash_detail'
            ,url: layui.setter.baseUrl + '/alipayCash/detailList' //列表接口
            ,where: {
                cashId:id
                ,access_token: layui.data(layui.setter.tableName).access_token
            }
            ,id: 'tableReloadDetail'
            ,page: true
            ,cols: [[
                {field: 'cashUserId', title: '红包用户', align:'center'}
                ,{field: 'alipayLoginId', title: '账号快照', align:'center'}
                ,{title: '预计分账金额(元)', templet: '<div>{{ d.planAmount != null ? d.planAmount/100 : "" }}</div>', align:'center'}
                ,{title: '实际到账金额(元)', templet: '<div>{{ d.realAmount != null ? d.realAmount/100 : "" }}</div>', align:'center'}
                ,{field: 'status', title: '状态', templet: tplStatus, align:'center'}
            ]]
            ,skin: 'line'
        });
    })
</script>